#!/usr/bin/env sh
# SPDX-License-Identifier: LGPL-2.1-or-later
# test (some) efivar thread safety
#
# Copyright Jonathan Marler

set -e

if [ "x$TOPDIR" = "x" ] ; then
	TOPDIR="$(realpath "$(dirname "$0")/../")"
fi

rm -rf scratch
mkdir scratch

EFIVARFS_PATH=""
LD_LIBRARY_PATH=""
LIBEFIVAR_OPS=""

EFIVARFS_PATH=$(realpath scratch)/
LD_LIBRARY_PATH="${TOPDIR}/src/"
LIBEFIVAR_OPS=efivarfs
export EFIVARFS_PATH LD_LIBRARY_PATH LIBEFIVAR_OPS

test() {
	echo -n "testing $1 thread..."
	"${TOPDIR}/src/thread-test" -t "$1"
}

test 1
test 2
test 4
test 64
